<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 了解 -->
    <div id="app">
      <h2>vue3组件使用v-model - {{textvalue}} - {{ textvalue2 }}</h2>
      <child v-model:value1="textvalue" v-model:value2="textvalue2"></child>
      <!-- <child
        :model-value="textvalue"
        @update:modelvalue="newValue => textvalue = newValue"
      ></child> -->
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child = {
        props: ["value1", "value2"],
        emits: ["update:value1", "update:value2"],
        template: `
          <div>child组件 - 
            <input
              type="text"
              :value="value1"
              @input="$emit('update:value1', $event.target.value)"
            />
            <input
              type="text"
              :value="value2"
              @input="$emit('update:value2', $event.target.value)"
            />
          </div>
        `,
      };

      createApp({
        data() {
          return {
            textvalue: "123",
            textvalue2: "abc",
          };
        },
        components: {
          Child,
        },
      }).mount("#app");
    </script>
  </body>
</html>
